package com.lgx.mall.business.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;
import com.lgx.common.web.util.DateUtils;
import com.lgx.common.web.util.DictUtils;

/**
 * 充值信息
 * @author pengdeyi
 *
 */
@Entity
@Table(name="TM_RECHARGEINFO")
public class RechargeInfo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_RECHARGEINFO_ID)
	@TableGenerator(
			name = IdGenerator.TM_RECHARGEINFO_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_RECHARGEINFO_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	/**
	 * 支付宝交易号
	 */
	private String tradeNo;

	/**
	 * 订单号
	 */
	private String orderNo;
	
	//充值用户ID
	@Column(name="user_id")
	private long userId;
	
	private String userName;//充值用户名
	
	private String userType;//充值用户类型
	
	private Date rechargeDate;//充值时间
	
	//充值商家ID
	@Column(name="merchant_id")
	private long orgId;
	
	private String orgName;//充值商家名称
	
	private String orgType;//充值商家类型
	
	private double amount;//充值金额
	
	private double score;//充值兑换金额数
	
	//充值确定人ID
	@Column(name="fixer_id")
	private long fixerId;
	
	private String fixerName;//充值确定人用户名
	
	private Date fixDate;//充值确定日期
	
	/**
	 * 1 未付款，2已付款，3未确认，4已确认
	 */
	private int status;//充值状态
	
	private String remarks;//备注
	
	private String isDelete;
	
	/**
	 * 1 手动充值  2 支付宝充值 3 网银充值
	 */
	private String type;//充值类型
	
	private String isRebate;//充值是否返利-----是否手动设置积分数量  1-返利,2-不返利
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getTradeNo() {
		return tradeNo;
	}

	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Date getRechargeDate() {
		return rechargeDate;
	}

	public void setRechargeDate(Date rechargeDate) {
		this.rechargeDate = rechargeDate;
	}

	public long getOrgId() {
		return orgId;
	}

	public void setOrgId(long orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getOrgType() {
		return orgType;
	}

	public void setOrgType(String orgType) {
		this.orgType = orgType;
	}

	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public double getScore() {
		return score;
	}

	public void setScore(double score) {
		this.score = score;
	}

	public long getFixerId() {
		return fixerId;
	}

	public void setFixerId(long fixerId) {
		this.fixerId = fixerId;
	}

	public String getFixerName() {
		return fixerName;
	}

	public void setFixerName(String fixerName) {
		this.fixerName = fixerName;
	}

	public Date getFixDate() {
		return fixDate;
	}

	public void setFixDate(Date fixDate) {
		this.fixDate = fixDate;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(String isDelete) {
		this.isDelete = isDelete;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getIsRebate() {
		return isRebate;
	}

	public void setIsRebate(String isRebate) {
		this.isRebate = isRebate;
	}

	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("userName", this.getUserName());
		obj.put("orgName", this.getOrgName());
		obj.put("amount", this.getAmount());
		obj.put("score", this.getScore());
		obj.put("rechargeDate", DateUtils.dateToChar(this.getRechargeDate(), DateUtils.DATE_FORMAT_T));
		obj.put("type", DictUtils.getDictNameByKindAndCode(DictUtils.RECHARGEINFO_TYPE, this.getType()+""));
		obj.put("statusName", DictUtils.getDictNameByKindAndCode(DictUtils.RECHARGEINFO_STATUS, this.getStatus()+""));    //状态名
		obj.put("status", this.getStatus());               //状态编号
		obj.put("fixerName", this.getFixerName());
		obj.put("fixDate", this.getFixDate()!=null?DateUtils.dateToChar(this.getFixDate(), DateUtils.DATE_FORMAT_T):"");
		return obj.toString();
	}
}
